home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / GUSI 1.4.1 / GUSI / Examples / GUSITest.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-25  |  1.7 KB  |  77 lines  |  [TEXT/MPS ]

  1. /*********************************************************************
  2. File        :    GUSI                -    Grand Unified Socket Interface
  3. File        :    GUSITest.h        -    Common testing gear
  4. Author    :    Matthias Neeracher <neeri@iis.ethz.ch>
  5. Language    :    MPW C
  6.  
  7. $Log: GUSITest.h,v $
  8. Revision 1.1  1994/02/25  02:48:06  neeri
  9. Initial revision
  10.  
  11. Revision 0.1  1992/09/08  00:00:00  neeri
  12. Factor out more common code
  13.  
  14. *********************************************************************/
  15.  
  16. typedef void (*TestCmd)(char ch1, char ch2, const char * restcmd);
  17.  
  18. #include <GUSITest_P.h>
  19.  
  20. #include <stdio.h>
  21.  
  22. extern FILE *  input;
  23. extern int        inputline;
  24.  
  25. /* void COMMAND(
  26.                  char ch1, char ch2,            Command name
  27.                 TestCmd p,                        Command to be run
  28.                 char *  s,                        Arguments to command
  29.                 char *  h);                        Explanation for command
  30.  
  31.     Example:
  32.         COMMAND('m', 'd', MkDir, "directory",            "Make a new directory");
  33. */
  34.  
  35. #define COMMAND(ch1,ch2,p,s,h)    \
  36.     DISPATCH(ch1,ch2)    =    (p),        \
  37.     USAGE(ch1,ch2)     =    (s),        \
  38.     HELPMSG(ch1,ch2)    =    (h)
  39.  
  40. /* An useful macro for dumping variables.
  41.     
  42.     Example:
  43.         DUMP(statbuf.st_dev,d);
  44. */
  45.  
  46. #define DUMP(EXPR, MODE)    printf("#    %s = %"#MODE"\n", #EXPR, EXPR)
  47.  
  48. /* Add common commands for sockets */
  49.  
  50. void AddSocketCommands();
  51.  
  52. /* Run the test. Define your commands with COMMAND and call this */
  53.  
  54. void RunTest(int argc, char ** argv);
  55.  
  56. /* Print a MPW executable location note */
  57.  
  58. void Where();
  59.  
  60. /* Print a prompt */
  61.  
  62. void Prompt();
  63.  
  64. /* Return a string of the current error number, e.g. "EINVAL" */
  65.  
  66. const char * Explain();
  67.  
  68. /* Print a usage message for a command */
  69.  
  70. void Usage(char ch1, char ch2);
  71.  
  72. /* Clean up sockets */
  73.  
  74. void CleanupSockets();
  75.  
  76. extern int sock;                /* Socket to read/write to                */
  77. extern int accsock;            /* Socket to accept connections on     */